/* eslint-disable no-shadow */
export function count({ search }) {
  return RSocket.rr({
    route: 'biz.channels.search.count',
    args: { search },
  });
}

export function search({ search, pg }) {
  return RSocket.rs({
    route: 'biz.channels.search',
    args: { search, pg },
  });
}

export function get(id) {
  return RSocket.rr({
    route: `biz.channels.${id}`,
  });
}

export function update(channel) {
  return RSocket.rr({
    route: 'biz.channels.update',
    data: channel,
  });
}

export function create(channel) {
  return RSocket.rr({
    route: 'biz.channels.create',
    data: channel,
  });
}

export function remove(id) {
  return RSocket.rr({
    route: `biz.channels.${id}.delete`,
  });
}

export function updateState({ id, state }) {
  return RSocket.rr({
    route: 'biz.channels.update.state',
    data: { id, state },
  });
}

/**
 * @description 获取公司
 * @param {*} args 参数
 * @returns array
 */
export function getCompany(args) {
  return RSocket.rs({
    route: 'companys',
    args: { ...args },
  });
}

/* 获取扫码链接 */
export function addProfitShare(type, targetId, period) {
  return RSocket.rr({
    route: 'commons.profit-share-account.bind',
    args: {
      targetType: type,
      targetId,
      period,
    },
  });
}

/**
* 获取酒店价格方案
* @param {*} '
*/
export async function getChanelPrice(id) {
  try {
    return await RSocket.rr({ route: `dmn.rules.channel-price-${id}.docs-by-type.TPricePlan` });
  } catch (__) {
    return await RSocket.rr({ route: 'dmn.rules.channel-price.docs-by-type.TPricePlan' });
  }
}

/**
 * 上传规则文件
 * @param {Buffer} fileData ;
 * @returns 成功返回字节数，否则异常
 */
export function uploadRule(fileData) {
  return RSocket.rc({
    route: 'dmn.rules.surcharge.upload',
    data: fileData,
    logLevel: 'trace',
  });
}

export function getTopItems(dictId) {
  return RSocket.rs({
    route: `dicts.${dictId}.items.top`,
  });
}

/**
 * 查询酒店信息
 * @param {*} args
 */
export function getMerchantInfo(id) {
  return RSocket.rr({
    route: `biz.merchants.${id}.ids`,
  });
}

/**
 * @description 获取包车订单数量
 * @returns true
 */
export function ordersCount({ search }) {
  return RSocket.rr({
    route: 'orders.search.count',
    args: { search },
  });
}

/**
 * 获取商户
 * @param { object } search
*/
// eslint-disable-next-line no-shadow
export function merchantsSearch({ search, pg }) {
  return RSocket.rs({
    route: 'biz.merchants.search',
    args: {
      search,
      pg,
    },
  });
}

/**
 * 获取商户数量
 * @param { object }  search pg
 */
// eslint-disable-next-line no-shadow
export function merchantsCount({ search }) {
  return RSocket.rr({
    route: 'biz.merchants.search.count',
    args: {
      search,
    },
  });
}

/**
 * 获取客户信息
 * @param { object }  search pg
 */
// eslint-disable-next-line no-shadow
export function getCustomers(search) {
  return RSocket.rr({
    route: 'customers.count',
    args: {
      ...search,
    },
  });
}

/**
 * 查询指定订单指定身份分润总计
 * @param { object }  search pg
 */
// eslint-disable-next-line no-shadow
export function getExcelsStatistics(args) {
  return RSocket.rr({
    route: 'cbv.excels.statistics.total.user',
    args: {
      ...args,
    },
  });
}
